const React = require('react');
const logo = require('./images/avatar.png');
require('./search.less');

// eslint-disable-next-line no-unused-vars
class Search extends React.Component {
  state = {
    Text: null,
  }

  loadComponent = () => {
    // 动态加载Text组件
    import('./text.js').then((Text) => {
      this.setState({ Text: Text.default });
    });
  }

  render() {
    const { Text } = this.state;
    return (
      <div className="search-text">
        Search Text Love you
        <br />
        加法结果：
        <div className="second-text">This is second title</div>
        { Text ? <Text /> : null }
        <img src={logo} onClick={this.loadComponent} alt="" />
      </div>
    );
  }
}

module.exports = <Search />;
